﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;

namespace MuAD
{
    internal static class SpeakHelper
    {
        internal static byte[] GetChatData()
        {
            List<byte> list = new List<byte>();
            StreamReader stream = null;
            try
            {
                stream = File.OpenText(AppDomain.CurrentDomain.BaseDirectory + "\\chat.txt");
                var text = stream.ReadLine();
                var bitTxt = text.Split(new char[] { ' ' }).ToList();

                byte d = 0;
                bitTxt.ForEach(x =>
                {
                    if (byte.TryParse(x, NumberStyles.HexNumber, null, out d))
                    {
                        list.Add(d);
                    }
                });
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
            return list.ToArray();
        }
    }
}
